package nodes.command;

import java.awt.Point;
import java.util.List;
import parser.ParserException;
import model.Model;
import model.Turtle;
import nodes.AbstractNode;
import nodes.ConstantNode;


/**
 * Moves all turtles to the home position and erases the drawing area
 */
public class ClearscreenC extends AbstractCommand
{
    private static final Point HOME_POINT = new Point(0,0);

    public AbstractNode evaluate (List<AbstractNode> myArguments, Model model)
    {
        if (myArguments.size() != Integer.parseInt(resources.getString("clearscreen")))
        {
            throw ParserException.BAD_ARGUMENTS;
        }

        int totalPixelsMoved = 0;
        List<Turtle> allTurtles = model.getAllTurtles();
        for(Turtle currentTurtle : allTurtles)
        {
           totalPixelsMoved += currentTurtle.setLocation(HOME_POINT);
        }
        
        model.clearscreen();
        return new ConstantNode(totalPixelsMoved);
    }
}
